#ifndef TIMMER_HPP
#define TIMMER_HPP

#include <chrono>

class Timer {
private:
  // Type aliases to make accessing nested type easier
  using clock_t = std::chrono::high_resolution_clock;
  using second_t = std::chrono::duration<double, std::ratio<1>>;

  std::chrono::time_point<clock_t> m_beg;
  std::chrono::time_point<clock_t> m_end;

public:
  Timer() : m_beg( clock_t::now() ) {}

  void reset() { m_beg = clock_t::now(); }

  void stop() { m_end = clock_t::now(); }

  double elapsed() {
    stop();
    return std::chrono::duration_cast<second_t>( m_end - m_beg ).count();
  }
};

#endif